#!/usr/bin/env node

const log=console.log;

let buf1=Buffer.alloc(256);
buf1[0]=0;
log('buf length:',buf1.length);
log('buf1:',buf1);

for(let i=0;i<buf1.length;i++) buf1[i]=i;
log('buf2:',buf1);

let buf2=buf1.slice(250,256);
log('\nbuf2:',buf2);

buf2.fill(0);
log('buf2:',buf2)
log('\nbuf2\'s JSON:',buf2.toJSON());
log('\nbuf2\'s JSON:',JSON.stringify(buf2));

let array=['a',0xba,0xdf,0x00,255,10];
let buf3=Buffer.from(array);

log('buf3:',buf3.length,buf3);

let buf4=Buffer.from('hello world','utf8');
log('buf4:',buf4.length,buf4)

buf4.copy(buf3,0,0,buf3.length);
log('buf3:',buf3.length,buf3);

let str='hhhhello worldddd'
let buf5=Buffer.from(str,'utf8');
log('\nbuffer length',buf5.length);
log('buffer content',buf5);
log('string length:',str.length);
